#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc, const char** argv)
{
    int btnState = 0;
    int fd = open("/dev/myBtnsDev", O_RDONLY | O_NONBLOCK);
    if(fd < 0)
    {
        perror("打开myBtns失败\n");
        return -1;
    }

    while(1)
    {
        int ret = read(fd,&btnState,sizeof(btnState));
        
        if(ret > 0)
        {
            printf("btnState = %x\n",btnState);
        }
        else
        {
            perror("read failed");
			printf("do other things...\n");
			sleep(1);
        }
    }
    close(fd);

    return 0;
}